<!--
 * @Author: tkp
 * @Date: 2024-03-29 10:17:43
-->
<template>
  <div>
    <el-form :model="queryForm" label-position="right" :rules="rules" ref="ruleForm" label-width="90px">
      <el-form-item prop="roleName" label="角色名称:">
        <Input v-model="queryForm.roleName" size="medium" clearable placeholder="请输入角色名称"></Input>
      </el-form-item>
      <el-form-item prop="roleCode" label="角色编码:">
        <Input v-model="queryForm.roleCode" size="medium" clearable placeholder="请输入角色编码"></Input>
      </el-form-item>
      <el-form-item prop="enable" label="是否启用:">
        <el-radio-group v-model="queryForm.enable">
          <el-radio :label="0">否</el-radio>
          <el-radio :label="1">是</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" size="medium" @click="okPop">确认</el-button>
        <el-button size="medium" @click="closePop">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      queryForm: {
        roleName: '',
        roleCode: '',
        enable: 0,
      },
      rules: {
        roleName: [
          { required: true, message: '此项为必填' },
        ],
        roleCode: [
          { required: true, message: '此项为必填' },
        ],
        enable: [
          { required: true, message: '此项为必填' },
        ],
      },
    }
  },
  mounted() { },
  methods: {
    closePop() {
      this.$emit('addData', '')
    },
    okPop() {
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          this.$emit('addData', this.queryForm)
        } else {
          this.messageWarnPop('请填写完整')
          return false;
        }
      });
    },
  }
}
</script>

<style lang="scss" scoped>
.fenrun_class {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 5px;
  .title {
    width: 100px;
  }
  .end {
    color: #999999;
  }
}
</style>
